﻿@{
    Layout = null;
    var list = ViewData["list"] as List<Pay.DTO.task_dto>;
    var bases = list.Where(x => x.task_category == 1).ToList();
    var Exclusive = list.Where(x => x.task_category == 2).ToList();
    var ad = ViewData["ad"] as Pay.DTO.ad_dto;
    string site_img = ViewData["site_img"] as string;
    var token_user_info = ViewData["TokenUser"] as token_user_info;
}

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>任务</title>
    <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0,maximum-scale=1.0, user-scalable=no" />
    <link rel="stylesheet" href="~/Content/css/base.css" />
    <link rel="stylesheet" href="~/Content/css/tuoken.css" />
    <script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <script type="text/javascript" src="~/Content/js/base.js"></script>
    <script src="~/Content/js/layer/1.9.3/layer.js"></script>
    <style type="text/css">
        .whitebtn {
            border: 1px solid #FF5A31;
            background-image: none !important;
            color: #FF5A31 !important;
        }

        .graybtn {
            background-image: linear-gradient(-90deg, #CBCBCB 0%, #CBCBCB 55%, #CBCBCB 100%) !important;
        }
    </style>
</head>
<body>
    <div class="header">
        <!-- <a href="javascript:history.go(-1);"><span class="back"></span></a> -->
        <div class="hdtitle">
            任务
        </div>
    </div>
    <div class="bodyct">
        <div class="taskbanner" style="@(ad != null ? string.Format("background:url('{0}'); background-size:100%", site_img + ad.img_url) : "")" ,
             onclick="@((ad != null && !string.IsNullOrEmpty(ad.link_url)) ? string.Format("clickAd('{0}','{1}')", ad.id,ad.link_url) : "")">
            <!-- <h1>赶紧收取马力，加速获取红钻</h1>
            <div class="ct"><h2>马力越多，获取的红钻会越多</h2></div> -->
        </div>
        <div class="basictask">
            <!-- 基础任务 -->
            <div class="basictask_title">
                <div class="basictask_titlect">
                    <div class="lf"></div>
                    <span>基础任务</span>
                    <div class="rg"></div>
                </div>
            </div>

            <div class="basictask_item">
                @if (bases != null && bases.Count > 0) {
                    foreach (var item in bases) {
                        var url = "";
                        if (token_user_info != null) {
                            if (item.type == Pay.TO.ETaskType.InviteRegister) {
                                url = "/Task/InviteRegister";
                            } else if (item.type == Pay.TO.ETaskType.FollowPubAccount) {
                                url = "/FollowPubAccount/Index";
                                if (!token_user_info.is_verify_no_card) { url = "javascript:layer.msg('请先实名认证')"; }
                            } else if (item.type == Pay.TO.ETaskType.Login) {
                                url = "";
                                if (!token_user_info.is_verify_no_card) { url = "javascript:layer.msg('请先实名认证')"; }
                            } else if (item.type == Pay.TO.ETaskType.Auth) {
                                if (token_user_info.status == CertifyStatus.None) { url = "/Task/Authentication"; }
                                else if (token_user_info.status == CertifyStatus.UnConfirm) { url = "/Task/AuthenticationUnConfirm"; }
                                else if (token_user_info.status == CertifyStatus.Auth) { url = "/Task/AuthenticationPass"; }
                                else if (token_user_info.status == CertifyStatus.Fail) { url = "/Task/AuthenticationNoPass"; }
                            }
                        } else {
                            url = "javascript:layer.msg('您还未登录无法操作')";
                        }
                        <a href="@url" class="link">
                            <i class="drill" style=" background-image:url(@string.Format("{0}{1}",site_img,item.logo_url))"></i>
                            <span class="info">@item.title</span>
                            @if (item.task_status == 1) {
                                if (item.is_complete) {
                                    <span class="btn">
                                        已完成
                                    </span>
                                } else {
                                    <span class="btn whitebtn">
                                        <em>+</em>@item.soup_value<text>马力</text>
                                    </span>
                                }
                            } else {
                                <span class=" btn graybtn ">
                                    <em>+</em>@item.soup_value<text>马力</text>
                                </span>
                            }

                            <div class="solid"></div>
                        </a>
                    }
                }
            </div>
            <!-- 独家任务 -->
            <div class="basictask_title">
                <div class="basictask_titlect">
                    <div class="lf"></div>
                    <span>独家任务</span>
                    <div class="rg"></div>
                </div>
            </div>
            <div class="basictask_item exclusive">
                @if (Exclusive != null && Exclusive.Count > 0) {
                    foreach (var item in Exclusive) {
                        var index = 1;
                        var url = "";
                        if (item.task_status == 1) {
                            if (item.type == Pay.TO.ETaskType.MerchIntroduce) {
                                url = "Merchant/MerchantList";
                            } else if (item.type == Pay.TO.ETaskType.GasFillingCard) {
                                url = "";
                            } else if (item.type == Pay.TO.ETaskType.MaYiBuLuo) {
                                url = ViewBag.mayi;
                            } else if (item.type == Pay.TO.ETaskType.CoinGold) {
                                url = "/Task/CoinGold";
                            } else if (item.type == Pay.TO.ETaskType.GeLunBu) {
                                url = "/Task/GeLunBu";
                            } else if (item.type == Pay.TO.ETaskType.ShiDaiYunShang) {
                                url = "/Task/ShiDaiYunShang";
                            } else if (item.type == Pay.TO.ETaskType.CreditCardApplication) {
                                url = "/card/FastCard";
                            } else if (item.type == Pay.TO.ETaskType.OpenTokenSupplier) {
                                url = "/Task/OpenSupplier";
                                if (!token_user_info.is_verify_no_card) { url = "javascript:layer.msg('请先实名认证')"; }
                            } else if (item.type == Pay.TO.ETaskType.CreditCard || item.type == ETaskType.ApplyLoan || item.type == ETaskType.CreditCardPointExchange || item.type == ETaskType.WatchLive || item.type == ETaskType.Maker) {
                                url = item.url;
                            }
                        }
                        <a href="javascript:clickTask('@item.id','@url')" class="link">
                            <i class="drill" style=" background-image:url(@string.Format("{0}{1}",site_img,item.logo_url))"></i>
                            <span class="info">@item.title</span>
                            @if (item.task_status == 1) {
                                if (item.is_complete) {
                                    <span class="btn">
                                        已完成
                                    </span>
                                } else {
                                    <span class="btn whitebtn">
                                        @if (item.type == Pay.TO.ETaskType.MaYiBuLuo) {<text>每日</text>}   <em>+</em>@item.soup_value<text>马力</text>
                                    </span>
                                }
                            } else {
                                <span class="btn graybtn ">
                                    @if (item.type == Pay.TO.ETaskType.MaYiBuLuo) {<text>每日</text>}   <em>+</em>@item.soup_value<text>马力</text>
                                </span>
                            }
                            <div class="solid"></div>
                        </a>
                        if (index == 3) {
                            <div class="cross"></div>
                        }
                        index++;
                    }
                }

            </div>
        </div>

        <div class="nomore">没有更多了</div>
    </div>
    </div>

    <!--底部-->
    <div class="footer">
        <a href="/Home/Index">
            <i></i>
            <span>基地</span>
        </a>
        <a href="/DistributionMall/Index">
            <i></i>
            <span>云商城</span>
        </a>
        <a href="/ProductTokenMaker/Index" class="on">
            <i></i>
            <span>创客导购</span>
        </a>
        @*<a href="/Consumption/Index">
                <i></i>
                <span>发现</span>
            </a>*@

        <a href="/User/My">
            <i></i>
            <span>我的</span>
        </a>
    </div>
    <script>
        //点击广告，记录点击数
        function clickAd(id, url) {
            $.ajax({
                url: '@Url.Action("GetAd","Ad")',
                async: false,
                type: 'POST',
                data: { id: id },
                success: function (result) {
                    window.location.href = url;
                }
            });
        }
        $('.footer a').click(function () {
            $(this).addClass('on').siblings().removeClass('on');
        });

        //点击任务
        function clickTask(id, url) {
            $.ajax({
                url: '@Url.Action("GetSoupTask", "Task")',
                async: false,
                type: 'POST',
                data: { taskId: id },
                success: function (result) {
                    if (result.result_code != 1000) { layer.msg(result.result_msg); return; }
                    else
                        window.location.href = url;
                }
            });

        }


    </script>
</body>
</html>